# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=pcodedmp
pkgname=('python2-pcodedmp' 'python-pcodedmp')
_pkgname=pcodedmp
pkgver=1.2.6
pkgrel=8
groups=('blackarch' 'blackarch-disassembler')
pkgdesc='A VBA p-code disassembler.'
arch=('any')
url='https://pypi.org/project/pcodedmp/#files'
license=('GPL3')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('bb8fb874b4140b517731b0de29b9ca1858d310d28c29806d224f6df59988d6bf8934756e14a8a9d913c665c469b23179a5edd10256c179d06d60a2a9f48fcabd')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-pcodedmp() {
  depends=('python2' 'python2-oletools')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" -O1 --skip-build

  for i in "$pkgdir/usr/bin/"*; do
    mv $i "${i}2"
  done
}

package_python-pcodedmp() {
  depends=('python' 'python-oletools')

  cd "$_pkgname-$pkgver"

  python setup.py install --prefix=/usr --root="$pkgdir" -O1 --skip-build
}

